package com.funcourse.demo.api.restful.io.response;

import com.funcourse.demo.api.restful.io.response.error.BusinessError;
import com.funcourse.demo.api.restful.io.response.error.CommonUsedError;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class ApiResponse<T> {

  Integer code;
  String msg;
  T body;

  public ApiResponse(BusinessError businessError,T body){
    this.code = businessError.getErrorCode();
    this.msg = businessError.getErrorMessage();
    this.body = body;
  }
  public static ApiResponse ok(Object body){
    return new ApiResponse(CommonUsedError.SUCCESS,body);
  }


}
